<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            游戏名称：<input type="text" name="name"/>
                        </li>

                        <!--<li>-->
                        <!--游戏简单信息：<input type="text" name="context"/>-->
                        <!--</li>-->

                        <!--<li>-->
                        <!--游戏详情介绍：<input type="text" name="text"/>-->
                        <!--</li>-->

                        <!--<li>-->
                        <!--logo图片链接：<input type="text" name="logo"/>-->
                        <!--</li>-->

                        <!--<li>-->
                        <!--游戏图片链接数组：<input type="text" name="imgs"/>-->
                        <!--</li>-->

                        <!--<li>-->
                        <!--安装包地址：<input type="text" name="apkAddress"/>-->
                        <!--</li>-->

                        <!--<li>-->
                        <!--创建时间：<input type="text" name="gmtCreate"/>-->
                        <!--</li>-->

                        <!--<li>-->
                        <!--修改时间：<input type="text" name="gmtModified"/>-->
                        <!--</li>-->

                        <li>
                            <!--来源：<input type="text" name="fromType"/>-->
                            <!--来源：<input type="text" name="fromType"/>-->
                            来源：<select name="fromType">
                            <option value="tencent">腾讯云</option>
                            <option value="custom">自定义</option>
                        </select>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
            <form method="POST" enctype="multipart/form-data" action="/system/gameInfo/import">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:gameInfo:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()"
                   shiro:hasPermission="system:gameInfo:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()"
                   shiro:hasPermission="system:gameInfo:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:gameInfo:export">
                    <i class="fa fa-download"></i> 导出
                </a>
                <a class="btn btn-primary" onclick="syncTencentGameInfo()" shiro:hasPermission="system:gameInfo:export">
                    <i class="fa fa-refresh"></i> 刷新腾讯云游戏信息
                </a>
                <a class="btn btn-primary">
                    <!--<i class="fa fa-imdb"></i> 导入-->
                    <input type="file" name="file" style="width: 165px"/>
                </a>

                <input type="submit" value="导入" class="btn btn-primary"/>

            </form>


        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:gameInfo:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:gameInfo:remove')}]];
    var prefix = ctx + "system/gameInfo";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "游戏",
            search: false,
            showExport: true,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'fromType',
                    title: '来源',
                    sortable: true,
                    formatter: function (value) {
                        switch (value) {
                            case 'tencent':
                                return '腾讯云';
                            case 'custom':
                                return '自定义';
                            default:
                                return value;
                        }
                    }
                },
                {
                    field: 'name',
                    title: '游戏名称',
                    sortable: true
                },
                {
                    field: 'context',
                    title: '游戏简单信息',
                    sortable: true
                },
                {
                    field: 'text',
                    title: '游戏详情介绍',
                    sortable: true,
                    // formatter: function(value, row, index) {
                    //     return $.table.tooltip(value);
                    // }
                },
                {
                    field: 'logo',
                    title: 'logo图片链接',
                    sortable: true
                },
                {
                    field: 'imgs',
                    title: '游戏图片链接数组',
                    sortable: true
                },
                {
                    field: 'apkAddress',
                    title: '安装包地址',
                    sortable: true
                },
                {
                    field: 'gmtCreate',
                    title: '创建时间',
                    sortable: true
                },
                {
                    field: 'gmtModified',
                    title: '修改时间',
                    sortable: true
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function syncTencentGameInfo() {
        var prodAddress = getProdAddress()
        var gameInfoSyncSuffix = [[${@config.getKey('game.gameInfo.sync')}]];
        doHttpGet(prodAddress + gameInfoSyncSuffix);
    }
    /**
     * 通过参数来获取线上服务器地址
     *
     */
    function getProdAddress() {
        var prodAddress =[[${@config.getKey('sys.prod.address')}]];
        return prodAddress;
    }
</script>
</body>
</html>